package com.arouter.demo.searchmodule.entity;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * desc: 也可实现 Serializable
 * 2018-06-01 09:54
 */
public class ObjParcelable implements Parcelable {
    private int id;
    private String name;

    public ObjParcelable(int id,String name){
        this.name = name;
        this.id = id;
    }

//    public void setId(int id) {
//        this.id = id;
//    }
//
//    public void setName(String name) {
//        this.name = name;
//    }

    protected ObjParcelable(Parcel in) {
        id = in.readInt();
        name = in.readString();
    }

    public static final Creator<ObjParcelable> CREATOR = new Creator<ObjParcelable>() {
        @Override
        public ObjParcelable createFromParcel(Parcel in) {
            return new ObjParcelable(in);
        }

        @Override
        public ObjParcelable[] newArray(int size) {
            return new ObjParcelable[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(name);
    }

    @Override
    public String toString() {
        return "ObjParcelable{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}
